package com.zdp.usercenter;

import com.zdp.usercenter.dao.user.UserMapper;
import com.zdp.usercenter.domain.entity.user.User;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.UUID;

/**
 * @author sesshomaru
 * @date 2020/9/16 23:04
 */
@RequiredArgsConstructor(onConstructor = @_(@Autowired))
@RestController
public class TestController {

    private final UserMapper userMapper;

    @PostMapping("/hello")
    public String hello(){
        return "hello";
    }

    @GetMapping("/test")
    public User testInsert(){
        User user = new User();
        user.setAvatarUrl("xxx");
        user.setWxId(UUID.randomUUID().toString());
        user.setBonus(100);
        user.setCreateTime(new Date());
        user.setUpdateTime(new Date());
        userMapper.insertSelective(user);
        return user;
    }

    // q?id=1&wxId=xxx... 这种请求
    @GetMapping("/q")
    public User query(User user){
        return user;
    }
}
